package com.frxuexi.park.adapter

import android.widget.TextView
import com.blankj.utilcode.util.TimeUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_base.entity.StatusBean
import com.frxuexi.lib_base.utils.DateTimeUtils
import com.frxuexi.park.R
import java.util.Calendar
import java.util.Date

class PreDateAdapter:BaseQuickAdapter<StatusBean,BaseViewHolder>(R.layout.item_predate) {
    override fun convert(helper: BaseViewHolder, item: StatusBean) {
        helper.getView<TextView>(R.id.pre_day).apply {
            setText(DateTimeUtils.getDate2(item.content as Date))
            if(item.checked){
                setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_solid_blue)
                setTextColor(context.getColor(com.frxuexi.lib_base.R.color.white))
            }else{
                setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_solid_lightgray)
                setTextColor(context.getColor(com.frxuexi.lib_base.R.color.darkgray))
            }
        }
        helper.getView<TextView>(R.id.pre_week).apply {
            val calendar = Calendar.getInstance()
            calendar.time= Date()
            calendar.add(Calendar.DAY_OF_MONTH,1)

            if(DateTimeUtils.getDate2(item.content as Date)==DateTimeUtils.getDate2(Date())){
                setText("今天")
            }else if(DateTimeUtils.getDate2(item.content as Date)==DateTimeUtils.getDate2(calendar.time)){
                setText("明天")
            }else{
                setText(TimeUtils.getChineseWeek(item.content as Date))
            }
        }


    }
}